package huixue.cn.com.rxapp.util;

import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;

import huixue.cn.com.library.util.MD5;
import huixue.cn.com.rxapp.entity.DeviceInfo;

/**
 * Created by Administrator on 2018/8/3.
 */

public class SignUtil {

    public static  SortedMap<String, String> makeSignMap(Map<String, String> params){
        //传递公共参数
        SortedMap<String, String> newParams = new TreeMap<>();
        for(Map.Entry<String,String> entry : params.entrySet()){
            newParams.put(entry.getKey(),entry.getValue());
        }

        newParams.put("deviceID", DeviceInfo.mDeviceID);
        newParams.put("versionID", DeviceInfo.mVersionID);
        newParams.put("source", "zcx");
        newParams.put("phoneType", DeviceInfo.mPhoneType);
        newParams.put("requireStr",System.currentTimeMillis() + "");

        StringBuffer sb = new StringBuffer("");
        for(Map.Entry<String,String> entry : newParams.entrySet()){
            sb.append(entry.getKey()).append(entry.getValue());
        }
        String sign = MD5.md5(sb.toString()).toUpperCase();
        newParams.put("sign", sign);

        return newParams;
    }

}
